<script>

    function hitung() {
        $('#total').val($("#service").val().split('|')[1] * $("#unit").val());
    }
    
    function post() {
        $.post('<?php echo base_url(); ?>reservation/saveServ/', {
            service_id: $("#service").val().split('|')[0],
            jumlah: $("#unit").val(),
            total: $('#total').val(),
            desc:$('#desc').val(),
            resv_id: <?php echo $resv_id; ?>
        }, function() {
            window.location.replace("");
        });
    }

</script>
<table class="table">
 <tr>
            <td>Date</td>
            <td>
                      <input id="date1" value="<?php echo date("Y-m-d h:m:s"); ?>" type="text" name="date" disabled>
                    
            </td>
        </tr>
    <tr>
        <td>Service Type</td>
        <td>
            <select id="service">
                <?php
                foreach ($data as $row) {
                    echo '<option value="' . $row['service_id'] . '|' . $row['service_price'] . '">' . $row['service_name'] . ' @'.$row['service_price'].'</option>';
                }
                ?></select><span id="price"></span>
        </td>
    </tr>
    <tr>
        <td>Quantity</td>
        <td>
            <input id="unit" type="number" /> <a class="btn btn-primary" href="javascript:void(0)" onclick="javascript:hitung();">=</a>
        </td>
    </tr>

    <tr>
        <td>Total</td>
        <td>
            <input id="total" type="number" disabled/>
        </td>
    </tr>

    <tr>
        <td>Description</td>
        <td>
            <textarea id="desc"></textarea>
        </td>
    </tr>
</table>
<a class="btn btn-primary" href="javascript:void(0)" onclick="javascript:post();">Save</a>
